package com.dominator.utils.system;

import java.util.Random;

/**
 * 验证码
 *
 * @author gsh
 */
public class VerifyCodeUtil {

    /**
     * 根据长度生成验证码
     * @param length
     * @return
     */
    public static String createVerifyCodeByLenth(int length) {
        StringBuilder sb = new StringBuilder();
        Random rand = new Random();
        for (int i = 0; i < length; i++) {
            sb.append(rand.nextInt(10));
        }
        String data = sb.toString();
        return data;
    }


    public static void main(String[] args) {
        System.out.println("随机数为" + createVerifyCodeByLenth(6));
        System.out.println("随机数为" + createVerifyCodeByLenth(4));

    }
}
